#include <stdio.h>
#include <algorithm>
using namespace std;

#define TRACE(x...)  
#define PRINT(x...) TRACE(printf(x))

int test;
int n;
int vec[10010];
int tam;
int a, b;
int _42;
int it;
int cont;

int main() {
	scanf("%d", &_42);

	while (_42--) {
		scanf("%d", &test);
		scanf("%d", &n);

		printf("%d %d\n", test, n/2+1);
		
		scanf("%d", &a);
		printf("%d", a);

		vec[0]=a;
		tam=1;
		cont=1;

		for (int i=0; i<(n/2); i++) {
			scanf("%d %d", &a, &b);

			for (it=tam-1; it>=0 && vec[it]>a; it--)
				vec[it+1]=vec[it];
		
			vec[it+1]=a;
			tam++;

			for (it=tam-1; it>=0 && vec[it]>b; it--)
				vec[it+1]=vec[it];

			vec[it+1]=b;
			tam++;


			TRACE(
				for (int j=0; j<tam; j++)
					printf("%d ", vec[j]);
				printf("\n");
			);	

			
			if (cont%10==0 && (i+1)<n/2)
				printf("\n%d", vec[tam/2]);
			else
				printf(" %d", vec[tam/2]);
			
			cont++;
		}
		
		printf("\n");
	}

	return 0;
}
